package demoMod.invincibleOne.patches;

import com.evacipated.cardcrawl.modthespire.lib.SpireInsertPatch;
import com.evacipated.cardcrawl.modthespire.lib.SpirePatch;
import com.evacipated.cardcrawl.modthespire.lib.SpirePostfixPatch;
import com.megacrit.cardcrawl.cards.AbstractCard;
import com.megacrit.cardcrawl.cards.DamageInfo;
import com.megacrit.cardcrawl.characters.AbstractPlayer;
import demoMod.invincibleOne.relics.TaskGoal;

import static demoMod.invincibleOne.relics.TaskGoal.alertQueue;

public class PreDrawPatch {
    public interface ICardPreDraw {
        // 每场战斗开始时，且抽卡前
        void onPreDraw();
    }

    @SpirePatch(
            clz = AbstractPlayer.class,
            method = "applyStartOfCombatPreDrawLogic"
    )
    public static class PatchDamage {
        @SpirePostfixPatch
        public static void Postfix(AbstractPlayer _instance) {
            for (AbstractCard c : _instance.masterDeck.group) {
                if (c instanceof ICardPreDraw) {
                    ((ICardPreDraw) c).onPreDraw();
                }
            }
            while (!alertQueue.isEmpty()) {
                TaskGoal.Alert a = alertQueue.poll();
                a.alertLambda.run();
            }
        }
    }
}
